<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="/resources/theme/metro-green/easyui.css" />
<link rel="stylesheet" type="text/css" href="/resources/theme/icon.css" />
<link rel="stylesheet" type="text/css" href="/resources/css/ui_custom.css" />
<link rel="stylesheet" type="text/css" href="/resources/css/design.css" />
<link rel="stylesheet" type="text/css" href="/resources/css/form.css" />
<title>고객 목록</title>
<script type="text/javascript" src="/resources/js/jquery-1.9.1.js"></script>
<script type="text/javascript" src="/resources/js/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/resources/js/jquery.jclock.js"></script>
<!-- <script type="text/javascript">
$(document).ready(function() {
	$('#west_collapse').click(function(){
		 $('.layout_center_inwrap').layout('collapse','west'); 
		 $('.layout_center_inwrap>div.panel.layout-expand').attr('title','Open');
	});
	$('.layout_center_inwrap').layout('panel','center').panel({
		onResize:function(){
			step1();
			step2();
		}
	});
	</script> -->
<%
String custlist = (String)request.getAttribute("custlist");
if(custlist.isEmpty() == false){
	System.out.print("\n custlist : "+custlist+"\n");
}else{
	System.out.print("\n custlist : null");
}

%>

<script type="text/javascript">
//담당자 validation 체크
       function cust_write(){
    	var obj = document.write;
        var result = false;
    	
        if(obj.CustName.value==""){
            alert("고객이름을 입력해주세요");
            obj.CustName.focus();
        }else if(obj.CustCode.value==""){
        	alert("고객코드를 입력해주세요");
            obj.CustCode.focus();
        }else if(obj.CustPhone.value==""){
        	alert("고객폰넘버를 입력해주세요");
            obj.CustPhone.focus();
        }else{
        	result = true;
        }
        
        return result;
    }
    
    function fncSubmit()
    {
        if(cust_write() == true) // chk 값이 true 일경우만 submit
        {
            document.write.submit();
        }
    }  

    //목록 클릭시 이벤트 발생
    function getSelected(){
        var row = $('#tt').datagrid('getSelected');
        if (row){
            $.messager.alert('Info', row.EmpIdx+":"+row.EmpName);
        }
    }
    function getSelections(){
        var ss = [];
        var rows = $('#tt').datagrid('getSelections');
        for(var i=0; i<rows.length; i++){
            var row = rows[i];
            ss.push('<span>'+row.empid+":"+row.EmpName+'</span>');
        }
        $.messager.alert('Info', ss.join('<br/>'));
    }
    

   /*  $('#tt').datagrid( {
    	onClickRow : function test(){
    		alert(1234);
    	}
    });  */
    
    $('#tt').datagrid({
    	onClickRow: function(index,field){
    		$(this).datagrid('beginEdit', EmpIdx);
    		var ed = $(this).datagrid('getEditor', {EmpIdx:EmpIdx,EmpName:EmpName});
    		$(ed.target).focus();
    		alert(1);
    	}
    });
    
    
    	
</script>

<!-- <div style="margin:10px 0;">
        <a href="#" class="easyui-linkbutton" onclick="getSelected()">GetSelected</a>
        <a href="#" class="easyui-linkbutton" onclick="getSelections()">GetSelections</a>
    </div> -->

<div data-options="region:'center',border:false" class="layout_center_center">
				<h1>고객목록</h1><br/>
				 <form name = "write" action="/custwrite.do" method = "post">
	                        <div><input type="text" name= "CustName" maxlength="5" size="12" style="width:10%" onKeyPress="fncSubmit();return false;">
	                        <div><input type="text" name= "CustCode" maxlength="5" size="12" style="width:10%" onKeyPress="fncSubmit();return false;">
	                        <div><input type="text" name= "CustPhone" maxlength="5" size="12" style="width:10%" onKeyPress="fncSubmit();return false;">
	                        <input type="button" value="저장" onClick="fncSubmit()"/></div>
				
				<table id="tt" class="easyui-datagrid" data-options="singleSelect:true,collapsible:true,rownumbers:true,fitColumns:true,data:data,pagination:true,fit:true,autoRowHeight:true">
			        <thead>
			            <tr>
			               <th field="CustIdx" width="0.5%"><b>CustIdx</b></th>
			               <th field="CustName" width="1%"><b>CustName</b></th>
			               <th field="CustCode" width="1%"><b>CustCode</b></th>
			               <th field="CustPhone" width="1%"><b>CustPhone</b></th>
			           </tr>
			        </thead>
			     </table>
	              </form>      
			</div>	
			
			
<script type="text/javascript">
 $(".nav li a.menu_07").addClass('active');  
var data = <%=custlist%>;
</script>
</head>
